📜 [專欄新文章] Gas Efficient Card Drawing in Solidity
✍️ Ping Chen
📥 歡迎投稿: https://medium.com/taipei-ethereum-meetup #徵技術分享文 #使用心得 #教學文 #medium
Assign random numbers as the index of newly minted NFTs
Scenario
The fun of generative art NFT projects depends on randomness. The industry standard is “blind box”, where both the images’ serial number and the NFTs’ index are predetermined but will be shifted randomly when the selling period ends. (They call it “reveal”) This approach effectively solves the randomness issue. However, it also requires buyers to wait until the campaign terminates. What if buyers want to know the exact card right away? We’ll need a reliable onchain card drawing solution.
The creator of Astrogator🐊 isn’t a fan of blind boxes; instead, it thinks unpacking cards right after purchase is more interesting.
Spec
When initializing this NFT contract, the creator will determine the total supply of it. And there will be an iterable function that is randomly picking a number from the remaining pool. The number must be in range and must not collide with any existing ones.
Our top priority is accessibility/gas efficiency. Given that gas cost on Ethereum is damn high nowadays, we need an elegant algorithm to control gas expanse at an acceptable range.
Achieving robust randomness isn’t the primary goal here. We assume there’s no strong financial incentive to cheat, so the RNG isn’t specified. Implementers can bring their own source of randomness that they think is good enough.
Implementation
Overview
The implementation is pretty short and straightforward. Imagine there’s an array that contains all remaining(unsold) cards. When drawIndex() is called, it generates a (uniform) random seed to draw a card from the array, shortens the array, and returns the selected card.
Algorithm
Drawing X cards from a deck with the same X amount of cards is equal to shuffling the deck and dealing them sequentially. It’s not a surprise that our algorithm is similar to random shuffling, and the only difference is turning that classic algo into an interactive version.
A typical random shuffle looks like this: for an array with N elements, you randomly pick a number i in (0,N), swap array[0] and array[i], then choose another number i in (1,N), swap array[1] and array[i], and so on. Eventually, you’ll get a mathematically random array in O(N) time.
So, the concept of our random card dealing is the same. When a user mints a new card, the smart contract picks a number in the array as NFT index, then grabs a number from the tail to fill the vacancy, in order to keep the array continuous.
Tweak
Furthermore, as long as the space of the NFT index is known, we don’t need to declare/initialize an array(which is super gas-intensive). Instead, assume there’s such an array that the n-th element is n, we don’t actually initialize it (so it is an array only contains “0”) until the rule is broken.
For the convenience of explanation, let’s call that mapping cache. If cache[i] is empty, it should be interpreted as i instead of 0. On the other hand, when a number is chosen and used, we’ll need to fill it up with another unused number. An intuitive method is to pick a number from the end of the array, since the length of the array is going to decrease by 1.
By doing so, the gas cost in the worst-case scenario is bound to be constant.
Performance and limitation
Comparing with the normal ascending index NFT minting, our random NFT implementation requires two extra SSTORE and one extra SLOAD, which cost 12600 ~ 27600 (5000+20000+2600) excess gas per token minted.
Theoretically, any instantly generated onchain random number is vulnerable. We can restrict contract interaction to mitigate risk. The mitigation is far from perfect, but it is the tradeoff that we have to accept.
ping.eth
Gas Efficient Card Drawing in Solidity was originally published in Taipei Ethereum Meetup on Medium, where people are continuing the conversation by highlighting and responding to this story.
👏 歡迎轉載分享鼓掌
同時也有16部Youtube影片,追蹤數超過109萬的網紅Okayu Ch. 猫又おかゆ,也在其Youtube影片中提到,_ ふにゃんふにゃ~~ん ‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐ 🐈猫又おかゆ 60万人記念ボイス販売中🐈 ‣販売ページはこちらから https://h...
「tail number」的推薦目錄:
- 關於tail number 在 Taipei Ethereum Meetup Facebook 的最讚貼文
- 關於tail number 在 Milton Goh Blog and Sermon Notes Facebook 的最佳解答
- 關於tail number 在 Focus Taiwan Facebook 的最讚貼文
- 關於tail number 在 Okayu Ch. 猫又おかゆ Youtube 的最讚貼文
- 關於tail number 在 Spice N' Pans Youtube 的最佳解答
- 關於tail number 在 ochikeron Youtube 的最佳貼文
- 關於tail number 在 How to determine the aircraft tail number on a particular flight? 的評價
- 關於tail number 在 Tin Tail Numbers - Home | Facebook 的評價
tail number 在 Milton Goh Blog and Sermon Notes Facebook 的最佳解答
Receive From God in Times of Prayer
“In nothing be anxious, but in everything, by prayer and petition with thanksgiving, let your requests be made known to God. And the peace of God, which surpasses all understanding, will guard your hearts and your thoughts in Christ Jesus.” (Philippians 4:6-7 WEB)
If you are handling stressful situations, remember to pray in tongues and cast that stress unto the Lord.
We have a tendency to be lazy to pray, and to just power through by our fleshly strength. Prayer is often seen as nice to have, or as a last resort. This is not the best way.
Back then, Jesus had many demands placed on Him. He had to minister to multitudes, and in the natural, that is very tiring.
We know that even Jesus got tired because He fell asleep in the boat, amidst the storm.
Jesus had a special way to recharge after dealing with highly-demanding situations. He spent a lot of time alone in the mountains to spend time with the Father in prayer.
“In these days, he went out to the mountain to pray, and he continued all night in prayer to God. When it was day, he called his disciples, and from them he chose twelve, whom he also named apostles: Simon, whom he also named Peter; Andrew, his brother; James; John; Philip; Bartholomew; Matthew; Thomas; James, the son of Alphaeus; Simon, who was called the Zealot; Judas the son of James; and Judas Iscariot, who also became a traitor. He came down with them, and stood on a level place, with a crowd of his disciples, and a great number of the people from all Judea and Jerusalem, and the sea coast of Tyre and Sidon, who came to hear him and to be healed of their diseases; as well as those who were troubled by unclean spirits, and they were being healed. All the multitude sought to touch him, for power came out of him and healed them all.” (Luke 6:12-19 WEB)
I believe that Jesus loved going to the mountains so that He could be ever so slightly closer to the Father. He missed being next to the Father in Heaven.
Another reason is that the mountain is desolate and with no distractions.
Spend time with God in many hours of prayer, away from your smartphone, and you will see amazing transformations happen.
When Jesus came down from the mountain, He was fully recharged, able to make right decisions quickly, and the power of the Holy Spirit easily flowed out from Him. Everyone who heard Jesus and touched Him received healing.
When handling stressful situations, if you do not pray, you will be drained. Even if you do not feel like it at first, spend time praying in tongues and with the understanding. Wake up an hour earlier if you have no time.
You will emerge from these sessions full of the anointing upon you, enabling you to handle the demands easily by God’s power and wisdom.
“But this is what has been spoken through the prophet Joel: ‘It will be in the last days, says God, that I will pour out my Spirit on all flesh. Your sons and your daughters will prophesy. Your young men will see visions. Your old men will dream dreams. Yes, and on my servants and on my handmaidens in those days, I will pour out my Spirit, and they will prophesy.” (Acts 2:16-18 WEB)
I believe we are in the tail end of the last days, and God is definitely pouring out His Spirit on all flesh. Position yourself to receive prophecy, dreams, and visions from the Lord. Make time to pray!
How do we receive more miracles from God? How does receiving by faith work under the New Covenant of Grace? These questions and more are answered in my book “Messiah’s Miracles: The Power of Having Faith in Jesus Christ” which is available in both digital and paperback formats. Some readers who read it gave great feedback, and I’m excited for you to get it and read too: https://bit.ly/messiahs-miracles
tail number 在 Focus Taiwan Facebook 的最讚貼文
An F-16 fighter jet overran a runway while attempting to land at an airbase in southern Taiwan on Tuesday, but the pilot was not injured, according to the Air Force Command Headquarters.
https://focustaiwan.tw/politics/202108310003
tail number 在 Okayu Ch. 猫又おかゆ Youtube 的最讚貼文
_
ふにゃんふにゃ~~ん
‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐
🐈猫又おかゆ 60万人記念ボイス販売中🐈
‣販売ページはこちらから
https://hololive.booth.pm/items/2430975
‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐
\ 🍙おにぎりゃー向けメンバーシップ🍙 /
❐メンバーに入るとこんな感じの特典が✨
‣名前の後ろに継続期間でグレードアップするバッジが!
‣専用の絵文字が使用できます(不定期で追加)
‣大体月一でメンバー限定配信(お悩み相談 セリフ読み)
‣壁紙やボイスが不定期更新されます!
【登録方法】
チャンネル登録ボタンの横にある「メンバーになる」ボタンから!
またはコチラのURLからどうぞ✨
https://www.youtube.com/channel/UCvaTdHTWBGv3MKj3KVqJVCw/join
‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐
🍙 Twitter:https://twitter.com/nekomataokayu
生放送関連タグ #生おかゆ ( 配信終わったら見てにまにましてる )
ファンアートタグ #絵かゆ ( 配信のサムネイルとして使用する場合があるよ! )
ファンネーム おにぎりゃー 🍙三🍙三🍙三
‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐
❐よくある質問をまとめてみたよ✨
Q.スパチャは読み上げられますか?
A.配信の一番最後にお名前を読み上げさせてもらうよ!いつもありがとう💖
Q.コメント欄が荒れてるよおかゆん~~!
A.焦らなくて大丈夫!運営さんが対応してくれたり僕が
気付いたら消したりするね( ^)o(^ )👍
最悪僕のことだけ見てて!そしたらきっと楽しいから✨
Q.問い合わせしたいことがあるよ!
A.フォームがあるからコチラに送信してみてね!
https://cover-corp.com/contact/
Q.お手紙は送れますか?
A.送れるよ!届いたら見てにまにましてます😎✌
以下から確認してね!
規約‣https://www.hololive.tv/contact
〒173-0003 東京都板橋区加賀1丁目6番1号 ネットデポ新板橋
カバー株式会社 ホロライブ プレゼント係分 猫又おかゆ宛
‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐
【 所属会社からのお知らせ 】
現在弊社タレントに対し、配信中のチャット等によりセンシティブな発言を誘発して、
炎上を引き起こそうとする事象が散見されています。
これに対し、NGワードを設定して予防を行っておりますが、
当該対応は政治的意図を含むものではなく、
タレントの安全な配信を担保するためである旨ご理解ください。
上記のとおり、炎上を故意に誘発しようとするユーザーによるチャットやコメントによって、
タレントが意図せずセンシティブな発言を行ってしまう可能性があります。
このような発言を行った場合にも、タレントには政治的・社会的意図は無いことを
予めご理解ください。
Notices From COVER Corporation
We have been made aware of a number of attempts to incite controversy against our talents by causing them to utter sensitive statements using the live stream chat.
In response to this, we have set up a list of terms unable to be mentioned at present to prevent this. Please understand that this response is not politically motivated and is intended to ensure the peaceful live streams by our talents.
Please understand that even if such statements were to be said by the talents, these are in no way politically or ideologically motivated.
tail number 在 Spice N' Pans Youtube 的最佳解答
Recently, we were so happy that the government of Hong Kong and Singapore set up a travel bubble. But, alas, due to the growing number of community cases in Hong Kong, both countries decide to postpone their plan. That inspired us to prepare some common Hong Kong dishes so that you can cook them and then imagine you're there in Hong Kong. We can get through this. Stay strong and stay safe.
See the ingredient list below for your easy reference.
Hope you can recreate this yummy dish in the comfort of your home. Happy cooking!
Thanks for dropping by our channel. Please subscribe to stay tuned to our home cooking videos.
Stalk us!
Youtube: www.youtube.com/spicenpans
Facebook www.facebook.com/spicenpans/
Instagram www.instagram/spicenpans
Website: www.spicenpans.com
Chat with us! info@spicenpans.com
Thanks for watching!
See you soon.
------------------
Hong Kong Chow Mein (Hong Kong Style Fried Noodles)
Ingredients:
Serves 4 pax
-------
Sauce mix
-------
80ml hot water
0.5 teaspoon sugar
2 tablespoons light soy sauce
2 tablespoons premium dark soy sauce
1 tablespoon oyster sauce
-------
Other ingredients
-------
200g dried egg noodles
220g beansprouts (remove the head and tail)
3 cloves of chopped garlic
60g chives
A few dashes of white pepper
1 tablespoon sesame oil
Some toasted sesame seeds (optional)
===
Don't know where to get the ingredients or don't know how they look like? See the links below.
Light soy sauce https://amzn.to/3dBZuBY
Premium dark soy sauce https://amzn.to/3lckuDa
Oyster sauce https://amzn.to/2VyjE9p
Chinese dried egg noodles (chow mein) https://amzn.to/36DIN90
White pepper https://amzn.to/3mJ6Jxm
Sesame oil https://amzn.to/37AveGU
----------
Looking for similar cooking equipment like the one we used in the video? These might interest you:
Granite pan (used for blanching) https://amzn.to/2V5v9oT
-------------
Filming equipment: iPhone 11 Pro Max (Get from Amazon https://amzn.to/3eA24tz)
Microphone: Sennheiser AVX digital wireless microphone system
Get Sennheiser wireless microphone in Singapore: https://singapore.sennheiser.com/products/avx-mke2-set-3-uk?_pos=2&_sid=adb86a9d8&_ss=r
Get Sennheiser wireless microphone from Amazon: https://amzn.to/2NILqMR
-----------------------------------
If you like this recipe, you might like these too:
Super Easy Restaurant Style Chinese Braised Noodles • Chicken Lo Mein 伊府面 Ee-Fu (Yee Fu) Mee Recipe
https://youtu.be/NR9O78XYKN4
Hong Kong Style Stir Fry Ramen Noodles w/ Chicken Chop 干炒鸡扒公仔面 Chinese Maggi Goreng Recipe
https://youtu.be/BAt4LlMzryY
The Ultimate Way to Fry Noodles! Quick Chinese Spicy Seafood Noodles 香辣炒面 Stir Fried Noodles Recipe
https://youtu.be/OeO8OAw4kDE
-----------------------------------
Disclaimer: Spice N' Pans is not related to these products and cannot guarantee the quality of the products in the links provided. Links are provided here for your convenience. We can only stand by the brands of the products we used in the video and we highly recommend you to buy them. Even then, preference can be subjective. Please buy at your own risk. Some of the links provided here may be affiliated. These links are important as they help to fund this channel so that we can continue to give you more recipes. Cheers!
tail number 在 ochikeron Youtube 的最佳貼文
Goldfish tomato is a simple yet Kawaii vegetable carving which anyone can make 😉 You can use this idea to garnish any dish you like 💖
Goldfish Tomatoes in Nagashi Somen (At-Home Fun Flowing Noodles Party Recipe)
https://www.youtube.com/watch?v=OOjnmdfA0QU
---------------------------------
Goldfish Tomato Somen Noodles (Kawaii Tomato Carving Garnish Idea) Recipe
Difficulty: Very Easy
Time: 15min
Number of servings: 4
Ingredients:
((Toppings))
grape tomatoes
cucumber slices
chopped green onions, etc...
((Somen Dipping Sauce))
* 300ml Dashi broth (using packaged dashi powder saves time) https://amzn.to/3ca6ypI
* 4 tbsp. Mirin (sweet Sake)
* 4 tbsp. soy sauce
((Somen Noodles))
dried Somen noodles
Directions:
((Somen Dipping Sauce))
In a pot, bring Dashi broth, Mirin, and soy sauce to a boil. You can also microwave until it comes to a boil. Cool in the fridge until ready to serve.
((Somen Noodles))
Boil water in a large pot. Add dried Somen noodles in boiling water and gently stir noodles with chopsticks. Cook Somen noodles according to your package (mine was 2 min). Drain the noodles in a strainer and rinse the noodles with hands under running water.
((Goldfish Tomato))
Wash and remove the stem. Place it stem side down. Slice the tail part, making sure you do not cut all the way through. Open and place the cut side down. Adjust the shape of the tail. Cut the fins. If you like, you can cut out sliced cheese and put some sesame seeds to make eyes.
I love using Kayanoya Dashi. Vegan/Vegetarian people can use Kombu or Vegetable Dashi broth for the dipping sauce 👍
https://amzn.to/3ca6ypI
↓レシピ(日本語)
https://cooklabo.blogspot.com/2020/07/Goldfish-Tomato.html
---------------------------------
Music by
YouTube Audio Library
Follow me on social media. If you have recreated any of my food, you can share some pictures #ochikeron. I am always happy to see them.
♥FOLLOW ME HERE♥
http://instagram.com/ochikeron/
https://www.facebook.com/ochikeron
https://plus.google.com/+ochikeron
http://twitter.com/ochikeron
♥My COOKBOOK available on Amazon Kindle♥
http://amzn.to/2EwR3ah
NO MORE hard copies... those who got one are lucky!
♥More Written Recipes are on my BLOG♥
http://createeathappy.blogspot.com/
♥My Recipe Posts in Japanese♥
http://cooklabo.blogspot.jp/
http://cookpad.com/ami
http://twitter.com/alohaforever
♥and of course PLEASE SUBSCRIBE♥
http://www.youtube.com/user/ochikeron?sub_confirmation=1
tail number 在 Tin Tail Numbers - Home | Facebook 的推薦與評價
AOPA gifted a Tin Tail Number replica sign to the generous folks that donated the AA-5B Grumman Tiger which AOPA will renovate and be giving away in their ... ... <看更多>
tail number 在 How to determine the aircraft tail number on a particular flight? 的推薦與評價
The step-to-step guide: 1. Search for Flight Number: Get hold of the flight number, such as LH123 or AA789 for instance. ... <看更多>
相關內容